#! /bin/bash

echo "
   MCL TEST SCRIPT - A COMPILE & TEST COMPONENT TESTS.

   Copyright (c) 2011, Sulaiman A. Mustafa

   This script is hereby released in the public domain. No other part of 
   this project is in the public domain unless explecitly stated so.
   
   If no copyright notic is present, then it is licensed under the the 
   Apache License, Version 2.0.



"


ext=".bin"
include=".."


SCLWHITE="\e[0;37m"
SCWHITE="\e[1;37m"
SCLPURPLE="\e[0;35m"
SCRED="\e[1;31m"
SCLRED="\e[0;31m"
SCLGREEN="\e[0;32m"
SCGREEN="\e[1;32m"
SCNONE="\e[0m"
SCLBLUE="\e[0;36m"
SCYELLOW="\e[0;33m"


compile(){
   echo -e "compiling next file ($1)... $SCWHITE"
   if [[ -f $1$ext ]]; then
      rm "$1$ext";
   fi
   gcc -I $include $@ -o "$1$ext";
   echo -ne $SCNONE
}
test(){
   echo -n "Testing $1$ext... "
   echo -ne $SCLGREEN
   ./$1$ext
   if [[ "$?" == "0" ]]; then
      echo -ne $SCNONE
      echo ".. pass"
   else
      echo -ne $SCRED
      echo -ne ".. fail"
      echo -ne $SCNONE
      exit 1
   fi
   rm ./$1$ext

}

cat list |
(
   while read l; do
      if [[ "$l" == "" ]]; then
         break;
      fi
      compile $l;
      test $l;
	done
)



